package com.newy.domain.sys;

import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.newy.core.hibernate.IdEntity;

/**
 * 菜单实体类
 * @author linzongxue
 *
 */
@Entity
@Table(name="sys_menu")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Menu extends IdEntity {	
	private Long parentId;
	private MenuType type;
	private String name;
	private String text;
	private String value;
	private String iconCls;
	private String tooltip;
	private Double sortNum;
	
	public Long getParentId() {
		return parentId;
	}
	public void setParentId(Long parentId) {
		this.parentId = parentId;
	}
	public MenuType getType() {
		return type;
	}
	public void setType(MenuType type) {
		this.type = type;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getText() {
		return text;
	}
	public void setText(String text) {
		this.text = text;
	}
	public String getValue() {
		return value;
	}
	public void setValue(String value) {
		this.value = value;
	}
	public String getIconCls() {
		return iconCls;
	}
	public void setIconCls(String iconCls) {
		this.iconCls = iconCls;
	}
	public String getTooltip() {
		return tooltip;
	}
	public void setTooltip(String tooltip) {
		this.tooltip = tooltip;
	}
	public Double getSortNum() {
		return sortNum;
	}
	public void setSortNum(Double sortNum) {
		this.sortNum = sortNum;
	}
	
	@Transient
	public boolean isFolder(){
		return this.getType() == MenuType.FOLDER;
	}

	@Transient
	public boolean isItem(){
		return this.getType() == MenuType.ITEM;
	}

	@Transient
	public boolean isButton(){
		return this.getType() == MenuType.BUTTON;
	}
	
	public enum MenuType {
		/** 菜单目录 */
		FOLDER("菜单目录"),
		/** 菜单项 */
		ITEM("菜单项"),
		/** 功能 */
		BUTTON("按钮");
		
		private String text;
		private MenuType(String text){
			this.text = text;
		};
		public String getText(){
			return text;
		}
	}
}
